#include "RequirementsGroup.h"
#include <iostream>
#include <QtDebug>

RequirementsGroup::RequirementsGroup(int numberRequired,
		QObject *parent)
	: QObject(parent)
{
	m_numberRequired = numberRequired;
	
	m_req1 = 0;
	m_req2 = 0;
	m_req3 = 0;
	m_req4 = 0;
	m_req5 = 0;
	m_req6 = 0;
	m_req7 = 0;
	m_req8 = 0;
	m_req9 = 0;
	m_req10 = 0;
	m_req11 = 0;
	m_req12 = 0;
	m_req13 = 0;
}

RequirementsGroup::~RequirementsGroup()
{
}
void RequirementsGroup::setReq(int number, int percent)
{
    switch (number)
    {
    case 1: m_req1 = percent; break;
    case 2: m_req2 = percent; break;
    case 3: m_req3 = percent; break;
    case 4: m_req4 = percent; break;
    case 5: m_req5 = percent; break;
    case 6: m_req6 = percent; break;
    case 7: m_req7 = percent; break;
    case 8: m_req8 = percent; break;
    case 9: m_req9 = percent; break;
    case 10: m_req10 = percent; break;
    case 11: m_req11 = percent; break;
    case 12: m_req12 = percent; break;
    case 13: m_req13 = percent; break;
    default:
        qWarning() << "ERROR: RequirementsGroup::setReq";
    }
}

int RequirementsGroup::requirement(int number)
{
    int percent = 0;
    switch(number)
    {
    case 1 : percent = m_req1; break;
    case 2 : percent = m_req2; break;
    case 3 : percent = m_req3; break;
    case 4 : percent = m_req4; break;
    case 5 : percent = m_req5; break;
    case 6 : percent = m_req6; break;
    case 7 : percent = m_req7; break;
    case 8 : percent = m_req8; break;
    case 9 : percent = m_req9; break;
    case 10 : percent = m_req10; break;
    case 11 : percent = m_req11; break;
    case 12 : percent = m_req12; break;
    case 13 : percent = m_req13; break;
    default:
        qWarning() << "ERROR: RequirementsGroup::setReq";
    }
    return percent;
}

int RequirementsGroup::numberRequired()
{
	return m_numberRequired;
}

int RequirementsGroup::completionPercentage()
{
    float completions = (float) (m_req1 + m_req2 +
                                 m_req3 + m_req4 +
                                 m_req5 + m_req6 +
                                 m_req7 + m_req8 +
                                 m_req9 + m_req10 +
                                 m_req10 + m_req11 +
                                 m_req12 + m_req13);
      
    int complete =(int) (completions / (float) m_numberRequired);
    if (complete > 100)
    	complete = 100;
    
    return complete;
}

int RequirementsGroup::req1() {return m_req1;}
int RequirementsGroup::req2() {return m_req2;}
int RequirementsGroup::req3() {return m_req3;}
int RequirementsGroup::req4() {return m_req4;}
int RequirementsGroup::req5() {return m_req5;}
int RequirementsGroup::req6() {return m_req6;}
int RequirementsGroup::req7() {return m_req7;}
int RequirementsGroup::req8() {return m_req8;}
int RequirementsGroup::req9() {return m_req9;}
int RequirementsGroup::req10() {return m_req10;}
int RequirementsGroup::req11() {return m_req11;}
int RequirementsGroup::req12() {return m_req12;}
int RequirementsGroup::req13() {return m_req13;}

void RequirementsGroup::setReq1(int percent) {m_req1 = percent;}
void RequirementsGroup::setReq2(int percent) {m_req2 = percent;}
void RequirementsGroup::setReq3(int percent) {m_req3 = percent;}
void RequirementsGroup::setReq4(int percent) {m_req4 = percent;}
void RequirementsGroup::setReq5(int percent) {m_req5 = percent;}
void RequirementsGroup::setReq6(int percent) {m_req6 = percent;}
void RequirementsGroup::setReq7(int percent) {m_req7 = percent;}
void RequirementsGroup::setReq8(int percent) {m_req8 = percent;}
void RequirementsGroup::setReq9(int percent) {m_req9 = percent;}
void RequirementsGroup::setReq10(int percent) {m_req10 = percent;}
void RequirementsGroup::setReq11(int percent) {m_req11 = percent;}
void RequirementsGroup::setReq12(int percent) {m_req12 = percent;}
void RequirementsGroup::setReq13(int percent) {m_req13 = percent;}
